﻿@model IEnumerable<StockShark.Models.Instrument>

<tr>
    <th>Nazwa waloru</th>
    <th>Rynek</th>
    <th>Kurs odn. (@Model.First().Unit)</th>
    <th>Kurs bieżący (@Model.First().Unit)</th>    
    <th>Zmiana (@Model.First().Unit)</th>
    <th>Zmiana (%)</th>
    @if (ViewBag.Title.Equals("Start"))
    {
    <th></th>
    }
</tr>
@foreach (var item in Model)
{
    <tr>
        <td>@Html.ActionLink(item.Name, "Details", "Quotations", new { item = item.Id }, null)</td>
        <td>@Html.DisplayFor(modelItem => item.Market)</td>
        <td>@Html.DisplayFor(modelItem => item.ReferencePrice)</td>
        @if (item.CurrentPrice > 0)
        { 
            if (item.CurrentPrice > item.ReferencePrice)
            {
                <td class="pos">@Html.DisplayFor(modelItem => item.CurrentPrice)</td>
            }
            else if (item.CurrentPrice < item.ReferencePrice)
            {
                <td class="neg">@Html.DisplayFor(modelItem => item.CurrentPrice)</td>
            }
            else
            {
                <td>@Html.DisplayFor(modelItem => item.CurrentPrice)</td>
            }
        }
        else
        { 
                <td>---</td>
        }
        @if (item.CurrentPrice > 0)
        { 
            if (item.CurrentPrice > item.ReferencePrice)
            {
                <td class="pos">@Html.DisplayFor(modelItem => item.Change)</td>
            }
            else if (item.CurrentPrice < item.ReferencePrice)
            {
                <td class="neg">@Html.DisplayFor(modelItem => item.Change)</td>
            }
            else
            {
                <td>0,00</td>
            }
        }
        else
        { 
                <td>---</td>
        }
        @if (item.CurrentPrice > 0)
        { 
            if (item.CurrentPrice > item.ReferencePrice)
            {
                <td class="pos">@Html.DisplayFor(modelItem => item.ChangePercent)</td>
            }
            else if (item.CurrentPrice < item.ReferencePrice)
            {
                <td class="neg">@Html.DisplayFor(modelItem => item.ChangePercent)</td>
            }
            else
            {
                <td>0,00</td>
            }
        }
        else
        { 
                <td>---</td>
        }
        @if (ViewBag.Title.Equals("Start"))
        {
        <td>            
            @Html.ActionLink("Usuń z listy", "Unwatch", "Home", new { item = item.Id }, null)
        </td>
        }
    </tr>
}